const { resolve } = require('path')

const Router = require('koa-router')
const router = new Router()

const { MANAGE_BASEROUTER } = require(resolve(__dirname, '../config/default'))

const { verifyToken } = require(resolve(__dirname, '../middleware/index'))

const {
  addTag,
  updateTag,
  delTags,
  selectTag,
  updateTagStatus,
  selectTagTotal
} = require(resolve(__dirname, '../routerHandle/managementHandle/tags'))

// 查询标签 /api/manage
router.get(MANAGE_BASEROUTER + '/tags/find', selectTag)

// 查询标签数量
router.get(MANAGE_BASEROUTER + '/tags/total', selectTagTotal)

// 添加标签 /api/manage
router.post(MANAGE_BASEROUTER + '/tags/add', verifyToken, addTag)

// 修改标签
router.post(MANAGE_BASEROUTER + '/tags/update', verifyToken, updateTag)

// 修改标签
router.post(MANAGE_BASEROUTER + '/tags/update/status', verifyToken, updateTagStatus)

// 删除标签
router.post(MANAGE_BASEROUTER + '/tags/del', verifyToken, delTags)

module.exports = router